package cn.tedu.csmall.stock.webapi.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface StockMapper {
    //修改(减少)指定商品的库存数的方法
    @Update("UPDATE stock_tbl " +
            "SET COUNT=COUNT-#{reduceCount} " +
            "WHERE commodity_code=#{commodityCode} " +
            "AND COUNT>=#{reduceCount}")
    int updateStockCount(@Param("commodityCode") String commodityCode,
                         @Param("reduceCount") Integer reduceCount);
}
